﻿using System;
using System.Collections.Generic;
using System.Text;
using System.IO;
using MediaPortal.Configuration;
using MediaPortal.GUI.Library;

using OpenSocialPlugin.General;
using OpenSocialPlugin.Providers;
using Facebook = OpenSocialPlugin.Providers.Facebook;

namespace OpenSocialPlugin
{
    public class Settings
    {
        public Dictionary<string, ISocialSite> Sites = new Dictionary<string, ISocialSite>();
        public Settings()
        {
            Sites.Add("Hi5", new Hi5());
            Sites.Add("Facebook", new Providers.Facebook());
            Sites.Add("PicasaWeb", new PicasaWeb());
            Sites.Add("Flickr", new Flickr());
        }

      public string PluginName { get; set; }

      public bool UseSMSStyleKeyBoard { get; set; }

      public string PictureDownloadFolder { get; set; }

      public void Load()
        {
            using (MediaPortal.Profile.Settings xmlreader = new MediaPortal.Profile.Settings(Config.GetFile(Config.Dir.Config, "MediaPortal.xml")))
            {
                this.PluginName = xmlreader.GetValueAsString("opensocial", "PluginName", "Social");
                this.UseSMSStyleKeyBoard = xmlreader.GetValueAsBool("opensocial", "UseSMSStyleKeyBoard", false);
                this.PictureDownloadFolder = xmlreader.GetValueAsString("opensocial", "PictureDownloadFolder", Environment.GetFolderPath(Environment.SpecialFolder.MyPictures));
            }
        }

        public void Save()
        {
            using (MediaPortal.Profile.Settings xmlwriter = new MediaPortal.Profile.Settings(Config.GetFile(Config.Dir.Config, "MediaPortal.xml")))
            {
                xmlwriter.SetValue("opensocial", "PluginName", this.PluginName);
                xmlwriter.SetValueAsBool("opensocial", "UseSMSStyleKeyBoard", this.UseSMSStyleKeyBoard);
                xmlwriter.SetValue("opensocial", "PictureDownloadFolder", this.PictureDownloadFolder);
            }
        }
    }
}
